package com.benefm.multipar.pad;

import android.app.Application;

import com.benefm.multipar.pad.ble.BLEManager;
import com.clj.fastble.BleManager;
import com.clj.fastble.scan.BleScanRuleConfig;

import java.util.LinkedList;

public class BaseApp extends Application {

    //    public static boolean isDebug = BuildConfig.DEBUG;
    public static boolean isDebug = true;

    public static BaseApp baseApp;

    //呼吸率的数据集合 1秒发送25个数据  共采集25*5 = 125组数据 进行滚动存储
    public LinkedList<Short> respData = new LinkedList<>();
    //呼吸波形数据对应的用户id
    public String respId;

    public static synchronized BaseApp getInstance() {
        return baseApp;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        baseApp = this;
        initBase();
    }


    public String getRespId() {
        return respId;
    }

    public void setRespId(String respId) {
        this.respId = respId;
    }


    /**
     * 蓝牙库初始化
     */
    public void initBase() {
        BleManager.getInstance().init(this);
        BleManager.getInstance()
                .enableLog(isDebug)
                .setSplitWriteNum(20)
                .setConnectOverTime(5000)
                .setOperateTimeout(5000);
        //过滤掉非善行的蓝牙设备
        BleScanRuleConfig scanRuleConfig = new BleScanRuleConfig.Builder()
                .setServiceUuids(BLEManager.SERVICE_UUIDS)
                .setScanTimeOut(8000)
                .build();

        BleManager.getInstance().initScanRule(scanRuleConfig);
    }


}
